/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmInfo.java
 *
 * Created on Aug 4, 2009, 2:31:43 PM
 */
package cconverter;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.jdesktop.application.Action;

/**
 *
 * @author SapunBoj
 */
public class FrmInfo extends javax.swing.JDialog {

    javax.swing.JDialog _this = this;
    java.awt.Frame parenti;

    /** Creates new form FrmInfo */
    public FrmInfo(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        parenti = parent;
        initComponents();
        btnOk.addActionListener(_exit);
    }

    public void setInfo(String title, String message) {
        lblInfo.setText(message);
        Dimension dm = lblInfo.getPreferredSize();
        this.setPreferredSize(new Dimension(dm.width + 30, dm.height + 80));
        this.setSize(new Dimension(dm.width + 30, dm.height + 80));
        this.setTitle(title);
        this.setResizable(false);
        Point _point = parenti.getLocation();
        this.setLocation(
                _point.x + (int) ((parenti.getSize().width - this.getSize().width) / 2),
                _point.y + (int) ((parenti.getSize().height - this.getSize().height) / 2));
        this.pack();
        this.setVisible(true);

    }
    ActionListener _exit = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            _this.dispose();
        }
    };

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblInfo = new javax.swing.JLabel();
        btnOk = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(cconverter.CConverterApp.class).getContext().getResourceMap(FrmInfo.class);
        lblInfo.setIcon(resourceMap.getIcon("lblInfo.icon")); // NOI18N
        lblInfo.setName("lblInfo"); // NOI18N

        btnOk.setText(resourceMap.getString("btnOk.text")); // NOI18N
        btnOk.setName("btnOk"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblInfo)
                .addContainerGap(302, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(221, Short.MAX_VALUE)
                .addComponent(btnOk, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblInfo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 81, Short.MAX_VALUE)
                .addComponent(btnOk)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                FrmInfo dialog = new FrmInfo(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    @Action
    public void _exit() {
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnOk;
    private javax.swing.JLabel lblInfo;
    // End of variables declaration//GEN-END:variables
}
